<?php


namespace App\Admin\Extensions;


use Illuminate\Support\Facades\Request;

class Grid extends \Encore\Admin\Grid
{

    /**
     * Get create url.
     *
     * @return string
     */
    public function getCreateUrl()
    {
        $queryString = '';

        $query = [];
        if ($constraints = $this->model()->getConstraints()) {
            $query = array_merge($query, $constraints);
        }

        $params = Request::input();
        $query = array_merge($query, $params);

        $queryString = http_build_query($query);

        return sprintf('%s/create%s',
            $this->resource(),
            $queryString ? ('?'.$queryString) : ''
        );
    }

}
